package net.tygzs.minerpg.CommandExecutor.MineItem;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

/**
 *
 * @author thtTNT
 */
public class MineItem implements CommandExecutor
{

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String args[])
    {
        try
        {
            if (args.length == 0)
            {
                Command_Help.sendHelp(sender, null);
                return true;
            }
            if (args[0].equalsIgnoreCase("help"))
            {
                if (args.length == 1)
                {
                    Command_Help.sendIndexOfHelp(sender, 1);
                    return true;
                }
                if (args.length == 2)
                {
                    int page = Integer.parseInt(args[1]);
                    Command_Help.sendIndexOfHelp(sender, page);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem help <页码> 获取关于插件的帮助");
                return true;
            }
            if (args[0].equalsIgnoreCase("create"))
            {
                if (args.length == 2)
                {
                    Command_Create.execut(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem create [物品名称] 创建一个物品");
                return true;
            }
            if (args[0].equalsIgnoreCase("give"))
            {
                if (args.length == 3)
                {
                    Command_Give.GiveItem(sender, args[1], args[2]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem give [物品名称] [玩家名称] 给予玩家指定RPG物品");
                return true;
            }
            if (args[0].equalsIgnoreCase("Damage"))
            {
                if (args.length == 3)
                {
                    Command_Damage.ChangeDamage(sender, args[1], Integer.parseInt(args[2]));
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Damage [物品名称] [伤害] 修改一个物品的伤害");
                return true;
            }
            if (args[0].equalsIgnoreCase("Dur"))
            {
                if (args.length == 3)
                {
                    Command_Dur.ChangeDur(sender, args[1], Integer.parseInt(args[2]));
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Dur [物品名称] [耐久度] 修改一个物品的耐久度");
                return true;
            }
            if (args[0].equalsIgnoreCase("Lore"))
            {
                if (args.length == 2)
                {
                    Command_Lore.sendLores(sender, args[1]);
                    return true;
                }
                if (args.length == 5)
                {
                    if (args[2].equalsIgnoreCase("edit"))
                    {
                        Command_Lore.editLore(sender, args[1], Integer.parseInt(args[3]), args[4]);
                        return true;
                    }
                }
                if (args.length == 4)
                {
                    if (args[2].equalsIgnoreCase("add"))
                    {
                        Command_Lore.addLore(sender, args[1], args[3]);
                        return true;
                    }
                    if (args[2].equalsIgnoreCase("del"))
                    {
                        Command_Lore.delLore(sender, args[1], Integer.parseInt(args[3]));
                        return true;
                    }
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Lore [物品名称] 查询一个物品的lore");
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Lore [物品名称] add [lore] 添加一条lore到一个物品");
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Lore [物品名称] edit [标号] [lore] 编辑一个物品的Lore");
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Lore [物品名称] del [标号] 删除一个物品的Lore");
                return true;
            }
            if (args[0].equalsIgnoreCase("name"))
            {
                if (args.length == 3)
                {
                    Command_Name.changeName(sender, args[1], args[2]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem name [物品名称] [显示名称] 修改一个物品的显示名称");
                return true;
            }
            if (args[0].equalsIgnoreCase("display"))
            {
                if (args.length == 2)
                {
                    Command_DisPlay.ChangeDisPlay(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem display [物品名称] 将手上的物品设置成一个物品的模型");
            }
            if (args[0].equalsIgnoreCase("list"))
            {
                Command_List.SendItemList(sender);
                return true;
            }
            if (args[0].equalsIgnoreCase("remove"))
            {
                if (args.length == 2)
                {
                    Command_Remove.removeItem(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem remove [物品名称] 删除一个物品模型");
                return true;
            }
            if (args[0].equalsIgnoreCase("type"))
            {
                if (args.length == 3)
                {
                    Command_Type.setType(sender, args[1], args[2]);
                    return true;
                }
                if (args.length == 1)
                {
                    Command_Type.sendTypeList(sender);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineItem Type [物品名称] <物品类型> 设置一个物品的类型");
                return true;
            }
            if (args[0].equalsIgnoreCase("armor"))
            {
                if (args.length == 4)
                {
                    if (args[2].equalsIgnoreCase("Fixed"))
                    {
                        Command_Armor.ChangeFixedArmor(sender, args[1], Integer.parseInt(args[3]));
                        return true;
                    }
                    if (args[2].equalsIgnoreCase("Sectional"))
                    {
                        Command_Armor.ChangeSectionalArmor(sender, args[2], Double.parseDouble(args[3]));
                        return true;
                    }
                    sender.sendMessage(ChatColor.YELLOW + "目前的参数有:Fixed(固定护甲值) Sectional(百分比护甲值)");
                }
                sender.sendMessage(ChatColor.YELLOW + "/MineRPG Armor [物品名称] [参数] [数值] 设置一个物品的护甲");
                sender.sendMessage(ChatColor.YELLOW + "目前的参数有:Fixed(固定护甲值) Sectional(百分比护甲值)");
                return true;
            }
            return true;
        } catch (NumberFormatException e)
        {
            sender.sendMessage(ChatColor.RED + "请输入正确的数字");
            return true;
        }
    }
}
